
import mirny, zipfile
from mirny.plugins.dissect import Dissect

class UnZip(Dissect):
	name = _('UnZip a file')
	description = _('Sample plugin to get cleartext files from a zip file')
	params = {	'file': (_('Path of the input zip file'), file, True), }
	config = {	'file': '', }
	types = ['application/zip']
	
	def init_plugin(self):
		self.source = zipfile.ZipFile(self.params)
		self.files = self.source.namelist()
	
	def next(self):
		try:
			self.file = self.files.pop()
			return True
		except IndexError:
			return False
	
	def read(self):
		return self.source.read(self.file)
	
